<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="vue.js"></script>
</head>

<body>
  <div id="app">
    <father></father>
    <hr>
    <father2></father2>
  </div>
  <template id="father">
      <div>
        我是父组件1
        <child>
          <h4>我是插槽在第一个父组件中的内容</h4>
          <button>按钮</button>
        </child>
      </div>
  </template>
  <template id="father2">
    <div>
      我是父组件2
      <child>
        <p>还代号为ID华为i</p>
      </child>
    </div>
</template>
  <script>
    let Child = {
      template:`
        <div>
          <h3>我是子组件</h3>
          <slot></slot> 
          <!--占位的插槽-->
        </div>
      `
    }
    
    let Father = {
      template:"#father",
      components:{
        Child
      }
    } 
    Vue.component("Father", Father);
    let Father2 = {
      template:"#father2",
      components:{
        Child
      }
    } 
    Vue.component("Father2", Father2);

    let vm = new Vue({
      el: "#app"
    })
  </script>
</body>

</html>